import { DynamicStructuredTool } from '@langchain/core/tools';

import { z } from 'zod';

// @ts-ignore
export default function () {
  return new DynamicStructuredTool({
    name: 'generate_bar_chart',
    description:
      'Generates a bar chart from an array of data points using D3.js and displays it for the user.',
    schema: z.object({
      data: z
        .object({
          label: z.string(),
          value: z.number(),
        })
        .array(),
    }),
    func: async ({ data }) => {
      console.table(data);
      return `Chart has been generated`;
    },
  });
}
